JPanel hedPanel = new JPanel(); JPanel fatPanel = new JPanel(); JPanel calPanel = new JPanel(); JPanel perPanel = new JPanel(); JPanel butPanel = new JPanel(); public PercentFatPanel() { setTitle( "Calories from Fat" ); outPer.setEditable( false ); setLayout( new FlowLayout() ); // set layout manager for the JFrame hedPanel.add( heading ); fatPanel.add( fatLabel ); fatPanel.add( inFat ); calPanel.add( calLabel ); calPanel.add( inCal ); perPanel.add( perLabel ); perPanel.add( outPer ); butPanel.add( doit ); . . . . }
Now add the panels to the frame.
This is being done in the constructor for the JFrame
so add()
means use the method of that frame.
Add the componentsto the frame from top to bottom